/********************************************************************
	filename: 	Vector2D.h
	created:	2010/04/16
	author:		Xiuwei Chen

	purpose:	Definition of class Vector2D

	All rights Reserved
*********************************************************************/

#pragma once

#include "Const.h"

class GEOMETRY_EXPORT Vector2D
{
public:

	/// <Summary>
	/// Zero of Vector2D
	/// </Summary>
	const static Vector2D Zero;
	
	/// <Summary>
	/// x coordinate
	/// </Summary>
	double x;

	/// <Summary>
	/// y coordinate
	/// </Summary>
	double y;
	
	/// <Summary>
	/// default constructor
	/// </Summary>
	Vector2D();

	/// <Summary>
	/// copy constructor
	/// </Summary>
	Vector2D(const Vector2D &v);

	/// <Summary>
	/// constructor
	/// </Summary>
	Vector2D(double _x, double _y);

	/// <Summary>
	/// set value
	/// </Summary>
	void SetValue(double _x, double _y);

	/// <Summary>
	/// overload operation: assignment
	/// </Summary>
	Vector2D & operator = (const Vector2D &v);

	/// <Summary>
	/// overload operation: "=="
	/// </Summary>
	bool operator == (const Vector2D &v) const;

	/// <Summary>
	/// overload operation: "!="
	/// </Summary>
	bool operator != (const Vector2D &v) const;

	/// <Summary>
	/// overload operation: "<"
	/// </Summary>
	bool operator < (const Vector2D &v) const;

	/// <Summary>
	/// overload operation: unary "-"
	/// </Summary>
	Vector2D operator - () const;

	/// <Summary>
	/// overload operation: "+"
	/// </Summary>
	Vector2D operator + (const Vector2D &v) const;

	/// <Summary>
	/// overload operation: "-"
	/// </Summary>
	Vector2D operator - (const Vector2D &v) const;

	/// <Summary>
	/// overload operation: "*" for scalar
	/// </Summary>
	Vector2D operator * (double f) const;

	/// <Summary>
	/// overload operation: "/" for scalar
	/// </Summary>
	Vector2D operator / (double f) const;

	/// <Summary>
	/// overload operation: self-converse "+="
	/// </Summary>
	Vector2D & operator += (const Vector2D &v);

	/// <Summary>
	/// overload operation: self-converse "-="
	/// </Summary>
	Vector2D & operator -= (const Vector2D &v);

	/// <Summary>
	/// overload operation: self-converse "*="
	/// </Summary>
	Vector2D & operator *= (double f);

	/// <Summary>
	/// overload operation: self-converse "/="
	/// </Summary>
	Vector2D & operator /= (double f);

	/// <Summary>
	/// vector Normalize
	/// </Summary>
	void Normalize();
	
	/// <Summary>
	/// overload operation: "*" for dot product
	/// </Summary>
	double operator * (const Vector2D &v) const;

	/// <Summary>
	/// get the module of vector
	/// </Summary>
	double Norm () const;

	/// <Summary>
	/// get the module square of vector
	/// </Summary>
	double Norm2 () const;

	/// <Summary>
	/// get projection on 2D vector
	/// </Summary>
	Vector2D Projection(const Vector2D &v) const;

	/// <Summary>
	/// get vertical vector (clockwise direction)
	/// </Summary>
	Vector2D Vertical(bool unit = false) const;

	/// <Summary>
	/// Translation by 2D vector
	/// </Summary>
	void Translation(const Vector2D &v);

	/// <Summary>
	/// rotate counter clockwise around the origin point (radian)
	/// </Summary>
	void Rotation(double angle);

	/// <Summary>
	/// rotate counter clockwise around a point (radian)
	/// </Summary>
	void Rotation(const Vector2D &p, double angle);

};

typedef Vector2D Point2D;
